package org.parademo.web.model;

import org.apache.commons.lang.StringUtils;
import org.springframework.validation.BindingResult;

public class TopicView {

    private String name;
    private String description;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void validateUsing(BindingResult bindingResult) {

        if (StringUtils.isEmpty(name)) {
            bindingResult.rejectValue("name", "topic.create.validation.name.required");
        }
        if (StringUtils.isEmpty(description)) {
            bindingResult.rejectValue("description", "topic.create.validation.description.required");
        }
    }
}
